package com.whosly.mysql.protocol.packet.impl.ok.data;

/**
 * @author 风杨
 * @see <a href="yueny09@163.com">mailTo: yueny09@163.com</a>
 */
public class OKDataBuilder {

    public static OKData build(Long pid, Long affectedRows){
        return build(pid, affectedRows, "");
    }

    public static OKData build(Long pid, Long affectedRows, String memo) {
        // 从上下文取相关信息
        Long elapsedMillCost = 0L;

        OKData okData = OKData.builder()
                .pid(pid)
                .affectedRows(affectedRows)
                .elapsedMillCost(elapsedMillCost)
                .memo(memo)
                .build();

        return okData;
    }
//
//    public static OKData build(IConnection conn, Long pid, Long affectedRows, String memo) {
//        // 从上下文取相关信息
//        Long elapsedMillCost = 0L;
//        if(conn != null){
//            Session session = SessionManager.getSessionManager().getSession(conn.getConnectionId());
//
//            if(session != null && session.getConnProcessContext(pid) != null){
//                IConnProcessContext connProcessContext = session.getConnProcessContext(pid);
//                DurationEx duration = connProcessContext.getDuration();
//                elapsedMillCost = (duration != null) ?  duration.getDuringMill() : 0L;
//            }
//        }
//
//        OKData okData = OKData.builder()
//                .pid(pid)
//                .affectedRows(affectedRows)
//                .elapsedMillCost(elapsedMillCost)
//                .memo(memo)
//                .build();
//
//        return okData;
//    }

}
